<?php

namespace App\Admin\Controllers;

use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;
use \App\Models\YaoDivination;
use \App\Models\Divination;
use \App\Models\ScenicArea;
use Encore\Admin\Facades\Admin;
use App\Services\MakeProductThumbnail\MakeProductThumbnail;
use App\Admin\Actions\DivinationAction\MakeDeepThinkByYao;

class YzyYaoDivinationController extends AdminController
{
    protected $title = '银子岩变爻配置';
    
    protected function grid()
    {
        $grid = new Grid(new YaoDivination());

	    $grid->disableExport();
	
	    $grid->column('id', 'ID');
	    $grid->column('divination_id', '本挂')->display(function () {
		    return $this->divination->title;
	    });
	     $grid->column('by_dividend_id', '变卦')->display(function () {
		    return $this->changeDivination->title;
	    });
	  
	    $grid->column('yao_count', '变爻数');
	   
	    $grid->column('created_at', '创建时间')->display(function () {
		    return $this->created_at->toDatetimeString();
	    });
	
	    $grid->disableRowSelector();
	    $this->gridActions($grid);
        return $grid;
    }
	
	protected function gridActions(Grid $grid) 
    {
	    $grid->actions(function (Grid\Displayers\Actions $actions) {
	    	$actions->disableDelete();

	   //  	if (in_array(Admin::user()->id, [1,2])) {
		  //   	$actions->add(new MakeDeepThinkByYao());

 			// }
		    
	    });
    }
	protected function detail($id)
    {
        $show = new Show(YaoDivination::findOrFail($id));
        return $show;
    }
	
    protected function form()
    {
        $form = new Form(new YaoDivination());
        
       
        $form->select('divination_id','本挂名称')->options(Divination::all()->pluck('title', 'id'))->rules('required');
	    $form->select('by_dividend_id','变挂名称')->options(Divination::all()->pluck('title', 'id'))->rules('required');
	    $form->number('yao_count', '变爻数')->default(0)->rules('required');

	    $form->textarea('wxsk', '五行生克.财运密码')->rules('required');
	    $form->textarea('yao_shiyi', '变爻释义')->rules('required');
	    $form->textarea('tag', '总结标签')->rules('required');
	   /* $form->textarea('wxzy', '五行增益.趋吉避凶攻略')->rules('required');*/


	    
        return $form;
    }

   
}
